package demo06递归;

public class Demo06 {

    //递归思想(调用次数太多影响机械性能)栈
    //实现阶乘
    public static void main(String[] args) {

        System.out.println(f(3))  ;
    }

    //5！-

    //2 2*f(1)
    //3 3*f(2)*f(1)
    public  static  int f(int n){

        if(n == 1){
            return 1;
        }else {
            return n * f(n - 1);
        }

    }
}
